package com.example.test.主方法运行测试;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.db.sql.SqlBuilder;
import com.example.test.bean.Tree;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

public class Main2 {


    public static void main(String[] ags) {


        List<String> stringList = Arrays.asList("1,2,3", "1,2,3,4", "1,2,3,4,5");


        String temp = null;
        for (String item : stringList) {


            if (temp == null) {
                temp = item;
                continue;
            }

            String[] temps = temp.split(",");
            String[] items = item.split(",");

            StringBuffer stringBuffer = new StringBuffer();
            for (String te : temps) {
                boolean flag = false;
                for (String it : items) {
                    if (it.equals(te)) {
                        flag = true;
                    }
                }
                if (flag) {
                    stringBuffer.append(te).append(",");
                }
            }

            temp = stringBuffer.substring(0, stringBuffer.length() - 1);

        }

        System.out.println(temp);


    }


}
